﻿using Newtonsoft.Json;

namespace Hpt.Device.Sample.Dto;

public class TransactionResponse : DeviceResponseBaseV1
{
    /// <summary>
    /// 持卡人姓名
    /// </summary>
    [JsonIgnore]
    public string UserName { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 3)]
    public string Name => UserName ?? "";

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Money", Order = 4)]
    public string CashBalance => Cash.ToString("F2");

    /// <summary>
    /// 剩余现金
    /// </summary>
    [JsonIgnore]
    public decimal Cash { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Subsidy", Order = 5)]
    public string SubsidyBalance => Subsidy.ToString("F2");

    /// <summary>
    /// 剩余补贴
    /// </summary>
    [JsonIgnore]
    public decimal Subsidy { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Times", Order = 6)]
    public string AvailableTimes => Times.ToString();

    /// <summary>
    /// 剩余次数
    /// </summary>

    [JsonIgnore]
    public int Times { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Integral", Order = 7)]
    public string IntegralString => Integral.ToString();

    /// <summary>
    /// 卡内剩余积分
    /// </summary>
    [JsonIgnore]
    public int Integral { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Dept", Order = 8)]
    public string Dept => Department ?? "";

    [JsonIgnore]
    public string Department { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Discount", Order = 9)]
    public string DiscountString => Discount.ToString();

    [JsonIgnore]
    public int Discount { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "QR", Order = 10)]
    public string QR => QRCode ?? "";

    [JsonIgnore]
    public string QRCode { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "CardType", Order = 11)]
    public string CardType => CardCatelog ?? "";

    [JsonIgnore]
    public string CardCatelog { get; set; }

    [JsonIgnore]
    public DateTime? In { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "InTime", Order = 12)]
    public string? InTime => In.HasValue ? In.ToString() : "";

    [JsonIgnore]
    public DateTime? Out { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "OutTime", Order = 13)]
    public string? OutTime => Out.HasValue ? Out.ToString() : "";

    [JsonIgnore]
    public decimal ChargeAmount { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Amount", Order = 14)]
    public string Amount => ChargeAmount.ToString("N2");

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "QROrder", Order = 15)]
    public string QROrderNumber { get; set; } = "";

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "PayResults", Order = 16)]
    public string PayResults { get; set; } = "";

    [JsonProperty(Order = 100)]
    public string QRCodeNumber { get; set; } = "";

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 1000)]
    public string Text { get; set; } = "";

    /// <summary>
    /// 水控级别
    /// </summary>
    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Level", Order = 17)]
    public string WaterLevel => Level.ToString();

    [JsonIgnore]
    public byte Level { get; set; }

    /// <summary>
    /// 卡编号
    /// </summary>
    [JsonIgnore]
    public int CardNumber { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "CardNumber", Order = 18)]
    public string CardNumberString => CardNumber.ToString();

    /// <summary>
    /// 水控有效期(开始),格式：yyyyMMddHHmmss
    /// </summary>
    public string StartTime { get; set; } = "";

    /// <summary>
    /// 水控有效期(结束),格式：yyyyMMddHHmmss
    /// </summary>
    public string EndTime { get; set; } = "";

    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "VoiceID", Order = 101)]
    public string? VoiceID => ((int?)VoiceTypeID)?.ToString();

    [JsonIgnore]
    public VoiceTypes? VoiceTypeID { get; set; }
}